home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #4 / Amiga Plus CD - 2000 - No. 4.iso / Tools / Grafik / Misc / ImageEnginer / ARexx / MotionBlur.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  1999-10-03  |  3.6 KB  |  150 lines

  1. /*
  2. ** $VER: MotionBlur.rexx 2.01, IE Arexx script
  3. ** Image Engineer Macro script
  4. ** Copyright © by Patrik M Nydensten
  5. ** 16/1 1997 Stockholm/Sweden
  6. **
  7. ** Creates a motion blur effect on image.
  8. ** Based on the MotionBlur.ieb 1.02 and requires rexxmathlib.library.
  9. **
  10. ** Support for saving last used results added by MS
  11. */
  12.  
  13. Options Results
  14. Signal On Error
  15.  
  16. if arg()==0 then exit
  17.  
  18. /* Get info from user */
  19.  
  20. if exists("ie:prefs/vemotionblur.cfg") == "1" then
  21.   do
  22.     call open("temp","ie:prefs/vemotionblur.cfg","R")
  23.     values=readln("temp")
  24.     parse var values ok method MixVal Angle Length Step Direc .
  25.     call close("temp")
  26.   end
  27. else
  28.   do
  29.     method=0
  30.     mixval=20
  31.     angle=0
  32.     length=32
  33.     step=2
  34.     direc=0
  35.   end
  36.  
  37. 'FORM "Motion Blur" "Ok|Cancel"',
  38. ' TEXT,"Motion Blur creates a `sweeping` blur effect."',
  39. ' CYCLE,"Method:","Mix (blurring)|Max (brighten)|Min (darken)",'method'',
  40. ' INTEGER,"Mix sharpness (Mix method only)",0,100,'mixval',SLIDER',
  41. ' INTEGER,"Angle:",0,359,'angle',SLIDER',
  42. ' INTEGER,"Length:",1,256,'length',SLIDER',
  43. ' INTEGER,"Step:",1,32,'step',SLIDER',
  44. ' CHECKBOX,"Blur both edges",'direc''
  45.  
  46. values=result
  47. parse var values ok Method MixVal Angle Length Step Direc .
  48.  
  49. if ok = 0 then exit
  50.  
  51. call open("temp","ie:prefs/vemotionblur.cfg","W")
  52. res=writeln("temp",values)
  53. call close("temp")
  54.  
  55.  
  56. if ok = 0 then exit
  57.  
  58. if Method == 0 then Method = "MIX"
  59. if Method == 1 then Method = "MAX"
  60. if Method == 2 then Method = "MIN"
  61.  
  62. /* Process image */
  63.  
  64. if add_mathlib() = '<ERROR>' then exit
  65.  
  66. 'PROJECT_INFO' arg(1) 'WIDTH'
  67. IW = RESULT
  68. 'PROJECT_INFO' arg(1) 'HEIGHT'
  69. IH = RESULT
  70.  
  71. 'SCALE' arg(1) IW IH 'FAST'
  72. LoadImage = Result
  73.  
  74. do until ((Angle < 360)&(Angle >= 0))
  75.   if Angle > 359 then Angle = Angle - 360
  76.   if Angle < 0 then Angle = Angle + 360
  77. end
  78.  
  79. if Method == 'MIX' then Method = 'MIX' MixVal
  80. Angle = 6.2831853 * Angle /360
  81.  
  82. if Direc == 0 then do /* Single */
  83.   'SCALE' LoadImage IW IH 'FAST'
  84.   BackImage = Result
  85.  
  86.   do i = 1 to Length by Step
  87.     'MARK' LoadImage 'PRIMARY'
  88.     'MARK' BackImage 'SECONDARY'
  89.     'COMPOSITE' (Length-i)*cos(Angle) (i-Length)*sin(Angle) Method
  90.     TempImage = Result
  91.     'CLOSE' BackImage
  92.     BackImage = TempImage
  93.   end
  94.  
  95.   'CLOSE' LoadImage
  96.   OutputImage = BackImage
  97. end
  98. else do  /* Both */
  99.   do i = 1 to Length by Step
  100.     'MARK' LoadImage 'PRIMARY'
  101.     'MARK' LoadImage 'SECONDARY'
  102.     'COMPOSITE' (Length-i)*cos(Angle) (i-Length)*sin(Angle) Method
  103.     TempImage = Result
  104.     'CLOSE' LoadImage
  105.     LoadImage = TempImage
  106.   end
  107.  
  108.   OutputImage = LoadImage
  109. end
  110.  
  111. back = 'OK'
  112.  
  113. exit
  114.  
  115. /* Internal procedures  ---------------------------------------------- */
  116.  
  117. add_mathlib:
  118.   if ~show(L,'rexxmathlib.library') then do
  119.     if exists('LIBS:rexxmathlib.library') then do
  120.       if ~addlib('rexxmathlib.library',0,-30,0) then do
  121.         'REQUEST' '"Failed to load libs:rexxmathlib.library!"' '" OK "'
  122.         return '<ERROR>'
  123.       end
  124.     end /* lib found on disk */
  125.     else do
  126.       'REQUEST' '"Failed to find libs:rexxmathlib.library!"' '" OK "'
  127.       return '<ERROR>'
  128.     end
  129.   end /* lib exists in mem */
  130. return 'OK'
  131.  
  132. /*******************************************************************/
  133. /* This is where control goes when an error code is returned by IE */
  134. /* It puts up a message saying what happened and on which line     */
  135. /*******************************************************************/
  136.  
  137. error:
  138. if RC=5 then do
  139.     IE_TO_FRONT
  140.     LAST_ERROR
  141.     'REQUEST "'||RESULT||'"'
  142. end
  143. else do
  144.     IE_TO_FRONT
  145.     LAST_ERROR
  146.     'REQUEST "Error detected!!!'||D2C(10)||'Image Engineer error message is as follows'||D2C(10)||result||D2C(10)||'Script failed on line '||SIGL||'"' ' OK '
  147. end
  148.  
  149. return '<ERROR>'
  150.